package com.mano233.server.controller;

import com.mano233.server.po.ResponseMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.atomic.AtomicInteger;

@Controller
public class BroadcastController {
    private static final Logger logger = LoggerFactory.getLogger(BroadcastController.class);

    // 收到消息记数
    private AtomicInteger count = new AtomicInteger(0);

    @MessageMapping("/receive")
    @SendTo("/topic/getResponse")
    public ResponseMessage broadcast(Object obj) {
        return null;
    }

    @RequestMapping(value = "/broadcast/index")
    public String broadcastIndex(HttpServletRequest req) {
        System.out.println(req.getRemoteHost());
        return "websocket/simple/ws-broadcast";
    }

}
